/**
 * Copyright 2006 The Apache Software Foundation
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.apache.ocean.main.fields;

import java.util.List;
import java.util.Map;

import org.apache.commons.lang.StringUtils;
import org.apache.ocean.main.IndexSchema;

import com.ibm.icu.text.Collator;
import com.ibm.icu.util.ULocale;

/**
 * 
 * 
 */
public class StringFieldType extends FieldType implements LocalizableFieldType {
	private ULocale locale;

	public StringFieldType() {
		typeName = "string";
	}

	public Class getType() {
		return String.class;
	}

	protected void init(IndexSchema.Category indexSchemaCategory, Map<String, String> args) {
		String localeString = args.get("locale");
		if (StringUtils.isNotBlank(localeString)) {
			locale = new ULocale(localeString);
		}
	}
  
	public List<CollatedField> getCollatedFields() {
		
	}
	
	// related to this field in that it is sortable by the specified collator
	public class CollatedField {
		private Collator collator;
		
		public Collator getCollator() {
			return collator;
		}
		
		public String getName() {
			
		}
	}
	
	public String objectToExternal(Object object) {
		return (String) object;
	}

	public String objectToIndexed(Object object) {
		return (String) object;
	}

	public Object stringToObject(String string) {
		return string;
	}

	public ULocale getLocale() {
		return locale;
	}
}
